﻿@inherits NFinal.View.RazorView<EnumModelData>
using System;
using System.Collections.Generic;
using System.Text;

namespace @(Model.NameSpace)
{
	/// <summary>
    @foreach(var commit in Model.SystemEnumInfo.Note.Split('\r','\n'))
	{
		if(!string.IsNullOrEmpty(commit))
		{
	@:/// @commit
		}
	}
    /// </summary>
    public enum @Model.SystemEnumInfo.Name
    {
		@foreach(var keyValue in Model.GetEnumList())
		{   
		@:@(keyValue.Value) = @(keyValue.Key),
		}
		/// <summary>
        /// 用于扩展方法调用
        /// </summary>
        卐 = int.MaxValue,
    }
}
namespace System
{
    public static class @(Model.SystemEnumInfo.Name)扩展类
    {
        /// <summary>
        /// 枚举转字符串
        /// </summary>
        /// <param name="enumValue"></param>
        /// <returns></returns>
        public static string GetName(this @(Model.NameSpace).@(Model.SystemEnumInfo.Name) enumValue,string defaultValue=null)
        {
            switch (enumValue)
            {
				@foreach(var keyValue in Model.GetEnumList())
				{   
				@:case @(Model.NameSpace).@(Model.SystemEnumInfo.Name).@(keyValue.Value): return "@(keyValue.Value)";
				}
                default:return defaultValue;
            }
        }
        /// <summary>
        /// 数字转枚举,扩展方法,请使用卐进行调用
        /// </summary>
        /// <param name="handler"></param>
        /// <param name="val"></param>
        /// <returns></returns>
        public static @(Model.NameSpace).@(Model.SystemEnumInfo.Name) GetEnum(this @(Model.NameSpace).@(Model.SystemEnumInfo.Name) 卐,int val)
        {
            return (@(Model.NameSpace).@(Model.SystemEnumInfo.Name))val;
        }
        /// <summary>
        /// 枚举转数字
        /// </summary>
        /// <param name="handler"></param>
        /// <param name="enumValue"></param>
        /// <returns></returns>
        public static int ToInt32(this @(Model.NameSpace).@(Model.SystemEnumInfo.Name) enumValue)
        {
            return (int)enumValue;
        }
        /// <summary>
        /// 获取枚举列表,扩展方法,请使用卐进行调用
        /// </summary>
        /// <param name="enumValue"></param>
        /// <returns></returns>
        public static List<KeyValuePair<int,string>> ToList(this @(Model.NameSpace).@(Model.SystemEnumInfo.Name) 卐)
        {
            List<KeyValuePair<int, string>> result = new List<KeyValuePair<int, string>>() {
				@foreach(var keyValue in Model.GetEnumList())
				{ 
                @:new KeyValuePair<int, string>(@(keyValue.Key),"@(keyValue.Value)"),
				}
            };
            return result;
        }
    }
}
